#include <stdio.h>
#include <math.h>
#include <stdlib.h>


//f(*p1>*p2) = 1
//f(*p1 == *p2) = 0
//f(*p1<*p2) =  - 1
int isEqual(char *p1,char *p2)
{
	char *pt1 = p1;
	char *pt2 = p2;
	while(*pt1 != '\0'&& *pt2 != '\0')
	{
		if(*pt1 > *pt2)
			return 1;
		else if(*pt1<*pt2)
			return -1;

		pt1++;
		pt2++;
	}

	if(*pt1 == '\0'&& *pt2 == '\0')  
	{
		return 0;
	}

	if(*pt1 == '\0') 
		return  -1;
	else if(*pt2 == '\0') 
		return 1;

	return 1;
}

int StringCompareTestMain(int argc,char **argv)
{
	char* keyWords[]={"for","while","do","double","float","int","const","char","if","else","switch","case","include"};

	char *p = "include";
	int charLength = sizeof(keyWords)/sizeof(keyWords[0]);

	int i;
	for(i = 0;i<charLength;i++)
	{
		if(isEqual(p,keyWords[i]) == 0) 
		{
			printf("%d\n",i + 1);
		}
	}

	return 0;
}
